package com.zy.web.demo.duoxiancheng.demo30;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author <a href="mailto:zhouyong@cqyyt.com">zy</a>
 * @version 1.0
 * @date 2020/9/2 11:20
 */
public class MyThread30 {

    private ReentrantLock lock = new ReentrantLock();

    public void methodA(){
        lock.lock();
        try {
            System.out.println(Thread.currentThread().getName()+":"+lock.getHoldCount());
            methodB();
        }finally {
            lock.unlock();
        }
    }

    public void methodB(){
        lock.lock();
        try {
            System.out.println(Thread.currentThread().getName()+":"+lock.getHoldCount());
        }finally {
            lock.unlock();
        }
    }

}
